/* 消息提示窗接口，使用必要引入 */
// 示例 AddMessage([类型], [消息])
// AddMessage("success", "成功消息")
// AddMessage("info", "信息消息")
// AddMessage("warning", "警告消息")
// AddMessage("error", "错误消息")

const body = document.body
const message = document.createElement("div")
message.className = "sugar-message"
message.id = "sugar-message"

const icon =  `
<svg t="1687683551100" class="icon icon-info" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4391" width="40" height="40"><path d="M512 85.333333a426.666667 426.666667 0 1 0 426.666667 426.666667A426.666667 426.666667 0 0 0 512 85.333333z m42.666667 597.333334a42.666667 42.666667 0 0 1-85.333334 0v-213.333334a42.666667 42.666667 0 0 1 85.333334 0z m-42.666667-298.666667a42.666667 42.666667 0 1 1 42.666667-42.666667 42.666667 42.666667 0 0 1-42.666667 42.666667z" p-id="4392"></path></svg>
<svg t="1687683511755" class="icon icon-error" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3355" width="40" height="40"><path d="M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m129.29219 233.447619l-129.267809 129.29219-129.316571-129.29219-51.736381 51.736381 129.316571 129.267809-129.316571 129.316571 51.736381 51.736381L512 563.687619l129.29219 129.316571 51.736381-51.73638L563.687619 512l129.316571-129.29219-51.73638-51.736381z" p-id="3356"></path></svg>
<svg t="1687682657827" class="icon icon-warning" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2597" width="30" height="30"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296z m32 440c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z" p-id="2598"></path></svg>
<svg t="1687683469643" class="icon icon-success" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2330" width="40" height="40"><path d="M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m193.194667 218.331428L447.21981 581.315048l-103.936-107.812572-52.662858 50.761143 156.379429 162.230857 310.662095-319.683047-52.467809-50.956191z" p-id="2331"></path></svg>
`

body.appendChild(message);

function AddMessage(type, text) {
    const messageContent = document.createElement("div")
    messageContent.className = "sugar-message-content"
    const msg = document.getElementById("sugar-message")
    messageContent.classList.add(type)
    messageContent.innerHTML = icon + text
    msg.appendChild(messageContent)
    setTimeout(()=>{
        msg.removeChild(messageContent)
    }, 3000)
}